package com.crx.springbootinit.service.impl;

import com.alibaba.excel.util.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.crx.springbootinit.mapper.LogLoginMapper;
import com.crx.springbootinit.model.dto.logLogin.LogLoginPageDTO;
import com.crx.springbootinit.model.dto.page.PageVO;
import com.crx.springbootinit.model.entity.LogLogin;
import com.crx.springbootinit.model.vo.logLogin.LogLoginPageVO;
import com.crx.springbootinit.service.ILogLoginService;
import org.springframework.stereotype.Service;

/**
 * @author 谢杭延
 * @Date 2024-10-28 20:23
 */
@Service
public class LogLoginServiceImpl extends ServiceImpl<LogLoginMapper, LogLogin> implements ILogLoginService {
    @Override
    public PageVO<LogLoginPageVO> queryLogLoginPage(LogLoginPageDTO logLoginPageDTO) {
        Integer pageNo = logLoginPageDTO.getPageNo();
        Integer pageSize = logLoginPageDTO.getPageSize();
        String requestType = logLoginPageDTO.getRequestType();
        Page<LogLogin> logLoginPage = new Page<>(pageNo, pageSize);
        Page<LogLogin> page = lambdaQuery()
                .eq(StringUtils.isNotBlank(requestType), LogLogin::getRequestType, requestType)
                .orderByDesc(LogLogin::getOperationTime)
                .page(logLoginPage);
        return PageVO.of(page, LogLoginPageVO.class);
    }
}
